package cn.sharp.bbs.service.impl;

import cn.sharp.bbs.dao.security.SecurityDao;
import cn.sharp.bbs.service.SecurityService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional
@Service
public class SecurityServiceImpl implements SecurityService {
    @Resource
    private SecurityDao securityDao;
    /**
     * 查询某个用户是否可以访问某个api
     * @param uid 用户id
     * @param api_path api路径
     * @return 布尔值, 代表是否可以访问
     */
    @Override
    public boolean isUserAbleToAccessApi(Long uid, String api_path) {
        return securityDao.countByUserAndApiPath(uid, api_path) > 0;
    }
}
